--/dbms: mssql
--/p ----------------------------
--/p Rumba for MSSQL (core)
--/p ----------------------------

--/p RBOrganization
drop table RBOrganization
--/ignore
go 
create table RBOrganization (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) not null,
   lastModifier VARCHAR(40) null,
   state INT null,
   code VARCHAR(20) not null,
   name VARCHAR(64) null,
   organizationDomain VARCHAR(38) not null,
   upperOrganization VARCHAR(38) null,
   levelId VARCHAR(16) null,
   remark VARCHAR(255) null,
   primary key (uuid)
)
go
create index idx_RBOrganization_1 on RBOrganization (domain)
go
create index idx_RBOrganization_3 on RBOrganization (organizationDomain)
go
create index idx_RBOrganization_2 on RBOrganization (code)
go

--/p TangoUserPermission
drop table TangoUserPermission
--/ignore
go
create table TangoUserPermission (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   permissionUUID VARCHAR(38) not null,
   userUUID VARCHAR(38) not null,
   primary key (uuid)
)
go

--/p TangoPermissionCommission
drop table TangoPermissionCommission
--/ignore
go
create table TangoPermissionCommission (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   permissionUUID VARCHAR(38) not null,
   fromUserUUID VARCHAR(38) not null,
   toUserUUID VARCHAR(38) not null,
   validFrom DATETIME null,
   validTo DATETIME null,
   primary key (uuid)
)
go

--/p RBDomainFuncView
drop table RBDomainFuncView
--/ignore
go
create table RBDomainFuncView (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) not null,
   funcView VARCHAR(128) not null,
   loadOrder INT not null,
   primary key (uuid)
)
go
create index idx_RBDomainFuncView_1 on RBDomainFuncView (domain, funcView)
go

--/p TangoUserRole
drop table TangoUserRole
--/ignore
go
create table TangoUserRole (
   uuid VARCHAR(255) not null,
   implementation VARCHAR(128) not null,
   roleUUID VARCHAR(38) not null,
   userUUID VARCHAR(38) not null,
   primary key (uuid)
)
go

--/p RBRoleDomain
--/ignore
drop table RBRoleDomain
go
create table RBRoleDomain (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   roleUuid VARCHAR(38) not null,
   domainUuid VARCHAR(38) not null,
   primary key (uuid)
)
go

--/p RBCartridge
drop table RBCartridge
--/ignore
go
create table RBCartridge (
   uuid VARCHAR(128) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) not null,
   lastModifier VARCHAR(40) null,
   state INT null,
   prefix VARCHAR(16) not null,
   caption VARCHAR(64) not null,
   version VARCHAR(32) not null,
   upgrading TINYINT not null,
   remark TEXT null,
   primary key (uuid)
)
go

--/p TangoDomain
drop table TangoDomain
--/ignore
go
create table TangoDomain (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) not null,
   lastModifier VARCHAR(40) null,
   state INT null,
   code VARCHAR(20) not null unique,
   name VARCHAR(50) null,
   remark VARCHAR(200) null,
   profile VARCHAR(38) null,
   profile2 VARCHAR(38) null,
   settleOrganization VARCHAR(38) null,
   taxCode VARCHAR(40) null,
   invoiceCode VARCHAR(40) null,
   bankAccount VARCHAR(40) null,
   isHeadQuarter TINYINT null,
   isCompany TINYINT null,
   isDc TINYINT null,
   isStore TINYINT null,
   isVendor TINYINT null,
   isCustomer TINYINT null,
   levelId VARCHAR(16) null,
   upperDomain VARCHAR(38) null,
   storeInstallTime DATETIME null,
   deliveryOrder INT null,
   orderDays INT null,
   customizedOrderDays INT null,
   dealRange VARCHAR(64) null,
   productStyle VARCHAR(64) null,
   transporter VARCHAR(1) null,
   alevel VARCHAR(1) null,
   profile3 VARCHAR(38) null,
   profile4 VARCHAR(38) null,
   primary key (uuid)
)
go
create index idx_Domain_1 on TangoDomain (domain)
go

--/p RBCartFunctionView
drop table RBCartFunctionView
--/ignore
go
create table RBCartFunctionView (
   uuid VARCHAR(128) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) not null,
   lastModifier VARCHAR(40) null,
   state INT null,
   cartridge_ VARCHAR(128) not null,
   prefix VARCHAR(16) not null,
   caption VARCHAR(64) not null,
   isAbstract TINYINT not null,
   remark TEXT null,
   primary key (uuid)
)
go
create index idx_RBCartFunctionView_1 on RBCartFunctionView (prefix)
go

--/p RBPrompt
drop table RBPrompt
--/ignore
go
create table RBPrompt (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) null,
   lastModifier VARCHAR(40) null,
   state INT null,
   receiverUser VARCHAR(38) null,
   receiverRole VARCHAR(38) null,
   senderId VARCHAR(38) not null,
   level_ INT not null,
   message VARCHAR(255) not null,
   link VARCHAR(255) not null,
   primary key (uuid)
)
go
create index idx_RBPrompt_3 on RBPrompt (senderId)
go
create index idx_RBPrompt_1 on RBPrompt (receiverUser)
go
create index idx_RBPrompt_2 on RBPrompt (receiverRole)
go

--/p RBActionLog
drop table RBActionLog
--/ignore
go
create table RBActionLog (
   uuid VARCHAR(38) not null,
   actionClass VARCHAR(128) not null,
   actionCaption VARCHAR(64) not null,
   primary key (uuid)
)
go

--/p RBDomainStoppedPermission
drop table RBDomainStoppedPermission
--/ignore
go
create table RBDomainStoppedPermission (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) not null,
   permission VARCHAR(38) null,
   primary key (uuid)
)
go
create index idx_RBDomainSP_1 on RBDomainStoppedPermission (domain)
go

--/p TangoRolePermission
drop table TangoRolePermission
--/ignore
go
create table TangoRolePermission (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   permissionUUID VARCHAR(38) not null,
   roleUUID VARCHAR(38) not null,
   primary key (uuid)
)
go

--/p TangoProfile
drop table TangoProfile
--/ignore
go
create table TangoProfile (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   email VARCHAR(255) null,
   phoneHome VARCHAR(255) null,
   phoneOffice VARCHAR(255) null,
   mobile VARCHAR(255) null,
   pager VARCHAR(255) null,
   msn VARCHAR(255) null,
   qq VARCHAR(255) null,
   postcode VARCHAR(255) null,
   birthday DATETIME null,
   wedding DATETIME null,
   favoriteColor VARCHAR(255) null,
   favoriteNumber VARCHAR(255) null,
   married TINYINT null,
   address1 VARCHAR(255) null,
   address2 VARCHAR(255) null,
   address3 VARCHAR(255) null,
   contactor VARCHAR(255) null,
   phone VARCHAR(255) null,
   website VARCHAR(255) null,
   fax VARCHAR(255) null,
   position VARCHAR(255) null,
   primary key (uuid)
)
go

--/p RBOrgRole
drop table RBOrgRole
--/ignore
go
create table RBOrgRole (
   uuid VARCHAR(38) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) not null,
   lastModifier VARCHAR(40) null,
   state INT null,
   type INT null,
   organization VARCHAR(38) null,
   primary key (uuid)
)
go
create index idx_RBOrgRole_1 on RBOrgRole (domain)
go

--/p TangoRole
drop table TangoRole
--/ignore
go
create table TangoRole (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) null,
   lastModifier VARCHAR(40) null,
   state INT null,
   code VARCHAR(100) not null,
   name VARCHAR(100) null,
   roleType INT null,
   remark VARCHAR(200) null,
   primary key (uuid)
)
go

--/p TangoUser
drop table TangoUser
--/ignore
go
create table TangoUser (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   domain VARCHAR(38) null,
   lastModifier VARCHAR(255) null,
   state INT null,
   FLogin VARCHAR(20) not null,
   name VARCHAR(20) null,
   FPassword VARCHAR(255) null,
   FOnline TINYINT null,
   validFrom DATETIME null,
   validTo DATETIME null,
   remark VARCHAR(200) null,
   profileUuid VARCHAR(38) null,
   departmentUuid VARCHAR(38) null,
   useToken TINYINT null,
   tokenSn VARCHAR(8) null,
   tokenPin VARCHAR(6) null,
   primary key (uuid)
)
go

--/p TangoPermission
drop table TangoPermission
--/ignore
go
create table TangoPermission (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   oca NUMERIC(19,0) not null,
   lastModified DATETIME null,
   code VARCHAR(100) not null unique,
   name VARCHAR(100) null,
   cartFuncViewUuid VARCHAR(128) null,
   providerType INT null,
   providerClassName VARCHAR(128) null,
   providerCaption VARCHAR(32) null,
   fieldCaption VARCHAR(32) null,
   remark VARCHAR(200) null,
   primary key (uuid)
)
go
create index idx_TangoPermission_1 on TangoPermission (cartFuncViewUuid, providerClassName, fieldCaption)
go

--/p RBProcessLog
drop table RBProcessLog
--/ignore
go
create table RBProcessLog (
   uuid VARCHAR(38) not null,
   implementation VARCHAR(128) not null,
   domain VARCHAR(38) not null,
   processClassName VARCHAR(128) not null,
   ownerKey1 VARCHAR(128) null,
   ownerKey2 VARCHAR(128) null,
   ownerKey3 VARCHAR(128) null,
   ownerKey4 VARCHAR(128) null,
   processUuid VARCHAR(38) not null,
   itemNo INT not null,
   processCaption VARCHAR(128) null,
   startTime DATETIME not null,
   operator VARCHAR(40) null,
   time DATETIME not null,
   type INT not null,
   message VARCHAR(255) null,
   primary key (uuid)
)
go
create index idx_RBProcessLog_1 on RBProcessLog (domain, processClassName, ownerKey1, ownerKey2, ownerKey3, ownerKey4, processUuid, itemNo)
go

--/p RBEntityChangeLog
drop table RBEntityChangeLog
--/ignore
go
create table RBEntityChangeLog (
   uuid VARCHAR(38) not null,
   fieldName VARCHAR(32) not null,
   fieldCaption VARCHAR(64) not null,
   oldValue VARCHAR(255) null,
   newValue VARCHAR(255) null,
   primary key (uuid)
)
go
create index idx_RBEntityChangeLog_1 on RBEntityChangeLog (fieldName)
go

--/p RBOperateLog
drop table RBOperateLog
--/ignore
go
create table RBOperateLog (
   uuid VARCHAR(38) not null,
   domain VARCHAR(38) not null,
   operator VARCHAR(40) not null,
   time DATETIME not null,
   settleNo VARCHAR(6) null,
   event VARCHAR(64) null,
   message VARCHAR(255) null,
   primary key (uuid)
)
go
create index idx_RBOperateLog_3 on RBOperateLog (settleNo)
go
create index idx_RBOperateLog_1 on RBOperateLog (domain)
go
create index idx_RBOperateLog_2 on RBOperateLog (time)
go

--/p RBEntityLog
drop table RBEntityLog
--/ignore
go
create table RBEntityLog (
   uuid VARCHAR(38) not null,
   managerClass VARCHAR(128) not null,
   managerCaption VARCHAR(64) not null,
   entityUuid VARCHAR(38) not null,
   entityCaption VARCHAR(64) not null,
   oldState INT null,
   newState INT null,
   primary key (uuid)
)
go
create index idx_RBEntityLog_1 on RBEntityLog (entityUuid, oldState, newState)
go

